<template>
    <rx-dialog @handOk="handleSubmit" @cancel="cancel" order="top" btnalign="right">
        <rx-layout>
            <div slot="center">
                <a-form-model ref="form" :rules="rules" :model="mdl" :label-col="labelCol" :wrapper-col="wrapperCol">
                    <a-form-model-item :label="i18n('form.name','名称')" prop="name">
                        <a-input :placeholder="i18n('form.name','名称','input')" v-model="mdl.name"/>
                    </a-form-model-item>
                    <a-form-model-item :label="i18n('form.resUser','资源库用户')" prop="resUser">
                        <a-input :placeholder="i18n('form.resUser','资源库用户','input')" v-model="mdl.resUser"/>
                    </a-form-model-item>
                    <a-form-model-item :label="i18n('form.resPwd','资源库密码')" prop="resPwd">
                        <a-input-password autoComplete="new-password" :placeholder="i18n('form.resPwd','资源库密码','input')" v-model="mdl.resPwd"/>
                    </a-form-model-item>

                    <a-form-model-item :label="i18n('form.dbType','数据库类型')" prop="dbType">
                        <a-select v-model="mdl.dbType">
                            <a-select-option value="MYSQL">MYSQL</a-select-option>
                            <a-select-option value="POSTGRES">POSTGRES</a-select-option>
                            <a-select-option value="ORACLE">ORACLE</a-select-option>
                        </a-select>

                    </a-form-model-item>
                    <a-form-model-item :label="i18n('form.host','主机地址')" prop="host">
                        <a-input :placeholder="i18n('form.host','主机地址','input')" v-model="mdl.host"/>
                    </a-form-model-item>

                    <a-form-model-item :label="i18n('form.port','端口号')" prop="port">
                        <a-input-number :placeholder="i18n('form.port','端口号','input')" v-model="mdl.port"/>
                    </a-form-model-item>

                    <a-form-model-item :label="i18n('form.database','数据库名')" prop="database">
                        <a-input :placeholder="i18n('form.database','数据库名','input')" v-model="mdl.database"/>
                    </a-form-model-item>

                    <a-form-model-item :label="i18n('form.username','用户名')" prop="user">
                        <a-input :placeholder="i18n('form.username','用户名','input')" v-model="mdl.user"/>
                    </a-form-model-item>

                    <a-form-model-item :label="i18n('form.password','密码')" prop="password">
                        <a-input-password autoComplete="new-password" :placeholder="i18n('form.password','密码','input')" v-model="mdl.password"/>
                    </a-form-model-item>

                    <a-form-model-item :label="i18n('form.remark','备注')" prop="comment">
                        <a-textarea :placeholder="i18n('form.remark','备注','input')" v-model="mdl.comment"/>
                    </a-form-model-item>

                    <a-form-model-item :label="i18n('form.status','状态')" prop="status">
                        <a-radio-group v-model="mdl.status">
                            <a-radio :value="1">{{i18n('form.enable','启用')}}</a-radio>
                            <a-radio :value="0">{{i18n('form.disable','禁用')}}</a-radio>
                        </a-radio-group>
                    </a-form-model-item>

                </a-form-model>


            </div>
        </rx-layout>
    </rx-dialog>
</template>
<script>
import SysKettleDbdefApi from '@/api/system/core/sysKettleDbdef'
import {RxDialog, BaseFormModel} from "@lowcode/jpaas-common-lib";


export default {
    name: 'SysKettleDbdefEdit',
    mixins: [BaseFormModel],
    components: {
        RxDialog,
    },
    data() {
        return {
            rules: {
                database: [{required: true, message: this.i18n('form.database','数据库名','input'), trigger: 'change'}],
                dbType: [{required: true, message: this.i18n('form.dbType','请输入数据库类型','select'), trigger: 'change'}],
                host: [{required: true, message: this.i18n('form.host','请输入主机地址','input'), trigger: 'change'}],
                name: [{required: true, message: this.i18n('form.name','请输入名称','input'), trigger: 'change'}],
                password: [{required: true, message: this.i18n('form.password','请输入密码','input'), trigger: 'change'}],
                port: [{required: true, message: this.i18n('form.port','请输入端口号','input'), trigger: 'change'}],
                resPwd: [{required: true, message: this.i18n('form.resPwd','请输入资源库密码','input'), trigger: 'change'}],
                resUser: [{required: true, message: this.i18n('form.resUser','请输入资源库用户','input'), trigger: 'change'}],
                status: [{required: true, message: this.i18n('form.status','请输入状态','select'), trigger: 'change'}],
                user: [{required: true, message: this.i18n('form.username','请输入用户名','input'), trigger: 'change'}],
            }
        }

    },
    methods: {
        i18n(name,text,key){
          return this.$ti18(name,text,"SysKettleDbdef",key);
        },
        get(id) {
            return SysKettleDbdefApi.get(id);
        },

        save() {
            return SysKettleDbdefApi.save(this.mdl);
        },
        onload_(data) {
            if (!data) {
                this.$set(this.mdl, "status", 1);
            }
        }

    }
}
</script>
<style>
.relick a {
    margin-right: 10px;
}

</style>
